home *** CD-ROM | disk | FTP | other *** search
/ Visual Cafe 3 / Visual Cafe 3.ISO / Vcafe / JFC.bin / SpecialCharTable.java < prev    next >
Text File  |  1998-06-30  |  9KB  |  177 lines

  1. /*
  2.  * @(#)SpecialCharTable.java    1.3 98/03/13
  3.  * 
  4.  * Copyright (c) 1997 Sun Microsystems, Inc. All Rights Reserved.
  5.  * 
  6.  * This software is the confidential and proprietary information of Sun
  7.  * Microsystems, Inc. ("Confidential Information").  You shall not
  8.  * disclose such Confidential Information and shall use it only in
  9.  * accordance with the terms of the license agreement you entered into
  10.  * with Sun.
  11.  * 
  12.  * SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF THE
  13.  * SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
  14.  * IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
  15.  * PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR ANY DAMAGES
  16.  * SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR DISTRIBUTING
  17.  * THIS SOFTWARE OR ITS DERIVATIVES.
  18.  * 
  19.  */
  20. package com.sun.java.swing.text.html;
  21.  
  22. import java.util.Vector;
  23. import java.io.*;
  24.  
  25. /**
  26.  * Translate Special Character codes into their ascii equivalent.
  27.  * 
  28.  * @author  Sara Swanson
  29.  * @version 1.3 03/13/98
  30.  */
  31.     class SpecialChar {
  32.     char symbol;
  33.     String name;
  34.  
  35.     public SpecialChar(char sym, String nm) {
  36.         symbol = sym;
  37.         name = nm;
  38.     }
  39.  
  40.     char getSymbol() {
  41.         return symbol;
  42.     }
  43.  
  44.     String getName() {
  45.         return name;
  46.     }
  47.  
  48.     }
  49.  
  50.     class SpecialCharTable {
  51.     SpecialChar[] specialCharTable = new SpecialChar[100];
  52.     int ts = 0;
  53.  
  54.     public SpecialCharTable() {
  55.         specialCharTable[ts] = new SpecialChar((char)34, "quot"); ts++;
  56.         specialCharTable[ts] = new SpecialChar((char)38, "amp"); ts++;
  57.         specialCharTable[ts] = new SpecialChar((char)60, "lt"); ts++;
  58.         specialCharTable[ts] = new SpecialChar((char)62, "gt"); ts++;
  59.         specialCharTable[ts] = new SpecialChar((char)160, "nbsp"); ts++;
  60.         specialCharTable[ts] = new SpecialChar((char)161, "iexcl"); ts++;
  61.         specialCharTable[ts] = new SpecialChar((char)162, "cent"); ts++;
  62.         specialCharTable[ts] = new SpecialChar((char)163, "pound"); ts++;
  63.         specialCharTable[ts] = new SpecialChar((char)164, "curren"); ts++;
  64.         specialCharTable[ts] = new SpecialChar((char)165, "yen"); ts++;
  65.         specialCharTable[ts] = new SpecialChar((char)166, "brvbar"); ts++;
  66.         specialCharTable[ts] = new SpecialChar((char)167, "sect"); ts++;
  67.         specialCharTable[ts] = new SpecialChar((char)168, "uml"); ts++;
  68.         specialCharTable[ts] = new SpecialChar((char)169, "copy"); ts++;
  69.         specialCharTable[ts] = new SpecialChar((char)170, "ordf"); ts++;
  70.         specialCharTable[ts] = new SpecialChar((char)171, "laquo"); ts++;
  71.         specialCharTable[ts] = new SpecialChar((char)172, "not"); ts++;
  72.         specialCharTable[ts] = new SpecialChar((char)173, "shy"); ts++;
  73.         specialCharTable[ts] = new SpecialChar((char)174, "reg"); ts++;
  74.         specialCharTable[ts] = new SpecialChar((char)175, "macr"); ts++;
  75.         specialCharTable[ts] = new SpecialChar((char)176, "deg"); ts++;
  76.         specialCharTable[ts] = new SpecialChar((char)177, "plusmn"); ts++;
  77.         specialCharTable[ts] = new SpecialChar((char)178, "sup2"); ts++;
  78.         specialCharTable[ts] = new SpecialChar((char)179, "sup3"); ts++;
  79.         specialCharTable[ts] = new SpecialChar((char)180, "acute"); ts++;
  80.         specialCharTable[ts] = new SpecialChar((char)181, "micro"); ts++;
  81.         specialCharTable[ts] = new SpecialChar((char)182, "para"); ts++;
  82.         specialCharTable[ts] = new SpecialChar((char)183, "middot"); ts++;
  83.         specialCharTable[ts] = new SpecialChar((char)184, "cedil"); ts++;
  84.         specialCharTable[ts] = new SpecialChar((char)185, "sup1"); ts++;
  85.         specialCharTable[ts] = new SpecialChar((char)186, "ordm"); ts++;
  86.         specialCharTable[ts] = new SpecialChar((char)187, "raquo"); ts++;
  87.         specialCharTable[ts] = new SpecialChar((char)188, "frac14"); ts++;
  88.         specialCharTable[ts] = new SpecialChar((char)189, "frac12"); ts++;
  89.         specialCharTable[ts] = new SpecialChar((char)190, "frac34"); ts++;
  90.         specialCharTable[ts] = new SpecialChar((char)191, "iquest"); ts++;
  91.         specialCharTable[ts] = new SpecialChar((char)192, "Agrave"); ts++;
  92.         specialCharTable[ts] = new SpecialChar((char)193, "Aacute"); ts++;
  93.         specialCharTable[ts] = new SpecialChar((char)194, "Acirc"); ts++;
  94.         specialCharTable[ts] = new SpecialChar((char)195, "Atilde"); ts++;
  95.         specialCharTable[ts] = new SpecialChar((char)196, "Auml"); ts++;
  96.         specialCharTable[ts] = new SpecialChar((char)197, "Aring"); ts++;
  97.         specialCharTable[ts] = new SpecialChar((char)198, "AElig"); ts++;
  98.         specialCharTable[ts] = new SpecialChar((char)199, "Ccedil"); ts++;
  99.         specialCharTable[ts] = new SpecialChar((char)200, "Egrave"); ts++;
  100.         specialCharTable[ts] = new SpecialChar((char)201, "Eacute"); ts++;
  101.         specialCharTable[ts] = new SpecialChar((char)202, "Ecirc"); ts++;
  102.         specialCharTable[ts] = new SpecialChar((char)203, "Euml"); ts++;
  103.         specialCharTable[ts] = new SpecialChar((char)204, "Igrave"); ts++;
  104.         specialCharTable[ts] = new SpecialChar((char)205, "Iacute"); ts++;
  105.         specialCharTable[ts] = new SpecialChar((char)206, "Icirc"); ts++;
  106.         specialCharTable[ts] = new SpecialChar((char)207, "Iuml"); ts++;
  107.         specialCharTable[ts] = new SpecialChar((char)208, "ETH"); ts++;
  108.         specialCharTable[ts] = new SpecialChar((char)209, "Ntilde"); ts++;
  109.         specialCharTable[ts] = new SpecialChar((char)210, "Ograve"); ts++;
  110.         specialCharTable[ts] = new SpecialChar((char)211, "Oacute"); ts++;
  111.         specialCharTable[ts] = new SpecialChar((char)212, "Ocirc"); ts++;
  112.         specialCharTable[ts] = new SpecialChar((char)213, "Otilde"); ts++;
  113.         specialCharTable[ts] = new SpecialChar((char)214, "Ouml"); ts++;
  114.         specialCharTable[ts] = new SpecialChar((char)215, "times"); ts++;
  115.         specialCharTable[ts] = new SpecialChar((char)216, "Oslash"); ts++;
  116.         specialCharTable[ts] = new SpecialChar((char)217, "Ugrave"); ts++;
  117.         specialCharTable[ts] = new SpecialChar((char)218, "Uacute"); ts++;
  118.         specialCharTable[ts] = new SpecialChar((char)219, "Ucirc"); ts++;
  119.         specialCharTable[ts] = new SpecialChar((char)220, "Uuml"); ts++;
  120.         specialCharTable[ts] = new SpecialChar((char)221, "Yacute"); ts++;
  121.         specialCharTable[ts] = new SpecialChar((char)222, "THORN"); ts++;
  122.         specialCharTable[ts] = new SpecialChar((char)223, "szlig"); ts++;
  123.         specialCharTable[ts] = new SpecialChar((char)224, "agrave"); ts++;
  124.         specialCharTable[ts] = new SpecialChar((char)225, "aacute"); ts++;
  125.         specialCharTable[ts] = new SpecialChar((char)226, "acirc"); ts++;
  126.         specialCharTable[ts] = new SpecialChar((char)227, "atilde"); ts++;
  127.         specialCharTable[ts] = new SpecialChar((char)228, "auml"); ts++;
  128.         specialCharTable[ts] = new SpecialChar((char)229, "aring"); ts++;
  129.         specialCharTable[ts] = new SpecialChar((char)230, "aelig"); ts++;
  130.         specialCharTable[ts] = new SpecialChar((char)231, "ccedil"); ts++;
  131.         specialCharTable[ts] = new SpecialChar((char)232, "egrave"); ts++;
  132.         specialCharTable[ts] = new SpecialChar((char)233, "eacute"); ts++;
  133.         specialCharTable[ts] = new SpecialChar((char)234, "ecirc"); ts++;
  134.         specialCharTable[ts] = new SpecialChar((char)235, "euml"); ts++;
  135.         specialCharTable[ts] = new SpecialChar((char)236, "igrave"); ts++;
  136.         specialCharTable[ts] = new SpecialChar((char)237, "iacute"); ts++;
  137.         specialCharTable[ts] = new SpecialChar((char)238, "iicrc"); ts++;
  138.         specialCharTable[ts] = new SpecialChar((char)239, "iuml"); ts++;
  139.         specialCharTable[ts] = new SpecialChar((char)240, "eth"); ts++;
  140.         specialCharTable[ts] = new SpecialChar((char)241, "ntilde"); ts++;
  141.         specialCharTable[ts] = new SpecialChar((char)242, "ograve"); ts++;
  142.         specialCharTable[ts] = new SpecialChar((char)243, "oacute"); ts++;
  143.         specialCharTable[ts] = new SpecialChar((char)244, "ocirc"); ts++;
  144.         specialCharTable[ts] = new SpecialChar((char)245, "otilde"); ts++;
  145.         specialCharTable[ts] = new SpecialChar((char)246, "ouml"); ts++;
  146.         specialCharTable[ts] = new SpecialChar((char)247, "divide"); ts++;
  147.         specialCharTable[ts] = new SpecialChar((char)248, "oslash"); ts++;
  148.         specialCharTable[ts] = new SpecialChar((char)249, "ugrave"); ts++;
  149.         specialCharTable[ts] = new SpecialChar((char)250, "uacute"); ts++;
  150.         specialCharTable[ts] = new SpecialChar((char)251, "ucirc"); ts++;
  151.         specialCharTable[ts] = new SpecialChar((char)252, "uuml"); ts++;
  152.         specialCharTable[ts] = new SpecialChar((char)253, "yacute"); ts++;
  153.         specialCharTable[ts] = new SpecialChar((char)254, "thorn"); ts++;
  154.         specialCharTable[ts] = new SpecialChar((char)255, "yuml"); ts++;
  155.     }
  156.  
  157.     char getSymbol(String name) {
  158.         for (int i=0; i<ts; i++) {
  159.         if(name.equalsIgnoreCase(specialCharTable[i].getName())) {
  160.             return(specialCharTable[i].getSymbol());
  161.         }
  162.         }
  163.         return 0;
  164.     }
  165.  
  166.     String getName(char sym) {
  167.         for (int i=0; i<ts; i++) {
  168.         if(sym == specialCharTable[i].getSymbol()) {
  169.             return(specialCharTable[i].getName());
  170.         }
  171.         }
  172.         return null;
  173.     }
  174.  
  175.     }
  176.  
  177.